package fi.jamk.ourcookingapp.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import fi.jamk.ourcookingapp.R;

/**
 * Adapter for showing the list with sorting values
 * @author Marius
 */
public class MySortingAdapter extends ArrayAdapter<String> {

	private Context context;
	
	private int resource;
	
	private String[] sortings;

	public MySortingAdapter(Context context, int resoucre, String[] strings) {
		super(context, resoucre, strings);
		this.context = context;
		this.resource = resoucre;
		this.sortings = strings;
	}
	
	@SuppressLint("ViewHolder")
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View rowView = inflater.inflate(resource, parent, false);
		String sort = sortings[position];
		TextView txtFriendName = (TextView) rowView.findViewById(R.id.text);
		txtFriendName.setText(sort);
		return rowView;
	}

}
